package test;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class CircleOut extends JPanel{
	/**
	 * 
	 */
	private static final long serialVersionUID = 4927366799736786908L;
	private int x;
	private int y;
	private int radius;
	
	public CircleOut()
	{
		this.x = 200;
		this.y = 200;
		this.radius = 0;
		setSize(400,400);
	}
	
	private void start() throws InterruptedException
	{
		while(true)
		{
			while(radius<=getWidth())
			{
				radius++;
				repaint();
				Thread.sleep(10);
			}
		
			while(radius >=0)
			{
				radius--;
				repaint();
				Thread.sleep(10);
			}
		}
	}
	
	@Override
	public void paint(Graphics g) {
		g.setColor(Color.cyan);
		g.fillRect(0, 0, getWidth(), getHeight());
		g.setColor(Color.GREEN);
		g.fillOval(x-(radius/2), y-(radius/2), radius, radius);
	}
	
	public static void main(String[] args)
	{
		CircleOut ta = new CircleOut();
		JFrame jf = new JFrame();
		jf.setSize(400, 400);
		jf.add(ta);
		jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jf.setVisible(true);
		try {
			ta.start();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
}

